package boot.spring.设计模式.访问者.访问者;

import boot.spring.设计模式.访问者.被访问者.Article;
import boot.spring.设计模式.访问者.被访问者.Book;
import boot.spring.设计模式.访问者.被访问者.LibraryItemInterface;

public class LibrarySumPrinterVisitor implements LibraryVisitor {

    int sum = 0;

    @Override
    public void visitor(Book library) {
        sum += library.getNums();
    }

    @Override
    public void visitor(Article library) {
        sum += library.getNums();
    }

    @Override
    public void printNum() {
        System.out.println("sum: "+sum);
    }
}
